﻿using System;
using System.Collections.Generic;
using System.Text;
using ArlesInterfaces.Editor;
using Arles.src.model;
using Arles.src.model.objects;
using Microsoft.Xna.Framework;
using System.Windows.Forms;

namespace Arles.src.controller.Commands
{
    class SkydomePropertiesCommand : Command<IEditor>
    {
        
        object newValue, oldValue;
        string field;

        public SkydomePropertiesCommand(IEditor editor, GridItem item, object oldValue)
            : base(editor, "SceneOptions", 1)
        {
            field = item.Label;
            newValue = item.Value;
            this.oldValue = oldValue;
        }
          

        public override void Execute()
        {
            SkydomeObject dome = (SkydomeObject)Editor.Instance.Scene.GetObject(ObjectType.Skydome);
            switch (field)
            {
                case "RealTime":
                    dome.RealTime = (bool)newValue;
                    break;
                case "Theta":
                    dome.Theta = (float)newValue;
                    break;
                case "Phi":
                    dome.Phi = (float)newValue;
                    break;
                case "NumDivisiones":
                    dome.NumDivisiones = (int)newValue;
                    break;
                case "TamH":
                    dome.TamH = (int)newValue;
                    break;
                case "TamV":
                    dome.TamV = (int)newValue;
                    break;
                case "WaveLengths":
                    dome.WaveLengths = (Vector3)newValue;
                    break;
                case "NumIteraciones":
                    dome.NumIteraciones = (int)newValue;
                    break;
                case "Exposicion":
                    dome.Exposicion = (float)newValue;
                    break;
                default:
                    break;
            }
            Editor.Instance.MainForm.Properties.Refresh();
        }

        public override void Undo()
        {
            SkydomeObject dome = (SkydomeObject)Editor.Instance.Scene.GetObject(ObjectType.Skydome);
            switch (field)
            {
                case "RealTime":
                    dome.RealTime = (bool)oldValue;
                    break;
                case "Theta":
                    dome.Theta = (float)oldValue;
                    break;
                case "Phi":
                    dome.Phi = (float)oldValue;
                    break;
                case "NumDivisiones":
                    dome.NumDivisiones = (int)oldValue;
                    break;
                case "TamH":
                    dome.TamH = (int)oldValue;
                    break;
                case "TamV":
                    dome.TamV = (int)oldValue;
                    break;
                case "WaveLengths":
                    dome.WaveLengths = (Vector3)oldValue;
                    break;
                case "NumIteraciones":
                    dome.NumIteraciones = (int)oldValue;
                    break;
                case "Exposicion":
                    dome.Exposicion = (float)oldValue;
                    break;
                default:
                    break;
            }
            Editor.Instance.MainForm.Properties.Refresh();
        }

        public override string toString()
        {
            SkydomeObject dome = (SkydomeObject)Editor.Instance.Scene.GetObject(ObjectType.Skydome);
            return dome.ToString();
        }
    }
}
